package com.zjsd.sqeybusiness.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zjsd.sqeybusiness.domain.Dlaccount;
import com.zjsd.sqeybusiness.service.IDlaccountService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 渠道代理账户信息Controller
 *
 * @author Zheng
 * @date 2022-05-10
 */
@RestController
@RequestMapping("/sqeybusiness/dlaccount")
public class DlaccountController extends BaseController
{
    @Autowired
    private IDlaccountService dlaccountService;

    /**
     * 查询渠道代理账户信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Dlaccount dlaccount)
    {
        startPage();
        List<Dlaccount> list = dlaccountService.selectDlaccountList(dlaccount);
        return getDataTable(list);
    }

    /**
     * 导出渠道代理账户信息列表
     */
    //@Log(title = "渠道代理账户信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Dlaccount dlaccount)
    {
        List<Dlaccount> list = dlaccountService.selectDlaccountList(dlaccount);
        ExcelUtil<Dlaccount> util = new ExcelUtil<Dlaccount>(Dlaccount.class);
        return util.exportExcel(list, "dlaccount");
    }

    /**
     * 获取渠道代理账户信息详细信息
     */
    @GetMapping(value = "/{accountid}")
    public AjaxResult getInfo(@PathVariable("accountid") Long accountid)
    {
        return AjaxResult.success(dlaccountService.selectDlaccountById(accountid));
    }

    /**
     * 新增渠道代理账户信息
     */
    //@Log(title = "渠道代理账户信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Dlaccount dlaccount)
    {
        return toAjax(dlaccountService.insertDlaccount(dlaccount));
    }


    //@Log(title = "渠道代理账户信息", businessType = BusinessType.INSERT)
    @PostMapping(value = "/queryZhye")
    public AjaxResult queryZhye(@RequestBody Dlaccount dlaccount)
    {
        Dlaccount dlaccount1 = dlaccountService.queryZhye(dlaccount);

        return AjaxResult.success(dlaccount1);
    }

    //@Log(title = "渠道代理账户信息", businessType = BusinessType.INSERT)
    @PostMapping(value = "/queryZhyeMobile")
    public AjaxResult queryZhyeMobile(Dlaccount dlaccount)
    {
        Dlaccount dlaccount1 = dlaccountService.queryZhye(dlaccount);

        return AjaxResult.success(dlaccount1);
    }

    /**
     * 修改渠道代理账户信息
     */
    //@Log(title = "渠道代理账户信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Dlaccount dlaccount)
    {
        return toAjax(dlaccountService.updateDlaccount(dlaccount));
    }

    /**
     * 删除渠道代理账户信息
     */
    //@Log(title = "渠道代理账户信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{accountids}")
    public AjaxResult remove(@PathVariable Long[] accountids)
    {
        return toAjax(dlaccountService.deleteDlaccountByIds(accountids));
    }
}
